//
//  SL_GrammarController.swift
//  SWIFT_LEARN
//
//  Created by youxin on 2018/1/15.
//  Copyright © 2018年 YST. All rights reserved.
//

import UIKit

class SL_GrammarController: UIViewController,UITableViewDelegate,UITableViewDataSource {
 
    let tabview = UITableView(frame:UIScreen.main.bounds, style:UITableViewStyle.plain)
    var datasoure :NSArray = NSArray()

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        datasoure = ["NS语法","UI语法","类与对象","其他"]
        self.cratUI()
        
    }
    
    func cratUI() {
        self.view.addSubview(tabview)
        tabview.dataSource = self;
        tabview.delegate = self;
        tabview.register(UITableViewCell.classForCoder(), forCellReuseIdentifier: "CELL");
        tabview.tableFooterView = UIView()
        
    }

    // UITableViewDelegate,UITableViewDataSource
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        
        return datasoure.count;
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        let cell : UITableViewCell  = UITableViewCell(style:UITableViewCellStyle.default,reuseIdentifier:"CELL");
        
        cell.textLabel?.text = (datasoure[indexPath.row] as! String)
        
        return cell
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        
        switch indexPath.row {
        case 0:
            let nsVC = GM_NsController()
            self.navigationController?.pushViewController(nsVC, animated: true)
        break
      
        case 1:
            let uiVC = GM_UIViewController()
            self.navigationController?.pushViewController(uiVC, animated: true)
            break
        
        case 2:
            let uiVC = GM_CLASSObjectController()
            self.navigationController?.pushViewController(uiVC, animated: true)
            break
            
        default: break
            
            
        }
        
    }
    

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    

    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}
